import { BaseEntity } from '@/types/base';

// 字段类型枚举
export const enum FieldType {
  TEXT = 'text',           // 文本框
  TEXTAREA = 'textarea',   // 文本域
  EDITOR = 'editor',       // 富文本编辑器
  IMAGE = 'image',         // 图片
  GALLERY = 'gallery',     // 图片集
  FILE = 'file',          // 文件
  VIDEO = 'video',        // 视频
  SELECT = 'select',       // 下拉选择
  RADIO = 'radio',        // 单选框
  CHECKBOX = 'checkbox',   // 复选框
  DATETIME = 'datetime',   // 日期时间
  NUMBER = 'number',       // 数字
  SWITCH = 'switch',      // 开关
  JSON = 'json'           // JSON对象
}

// 字段配置接口
export interface FieldConfig {
  fieldName: string;
  fieldKey: string;
  fieldType: FieldType | string;
  required?: boolean;
  searchable?: boolean;
  listable?: boolean;
  sort?: number;
  placeholder?: string;
  options?: string | Array<{label: string; value: string | number}>;
  width?: string | number;
  render?: string;
  defaultValue?: any;
  col?: number;  // 栅格列数
  group?: string; // 分组
  props?: Record<string, any>; // 组件属性
}

// 字段分组接口
export interface FieldGroup {
  title: string;
  name: string;
  icon?: string;
  fields: FieldConfig[];
}

// 字段渲染器接口
export interface FieldRenderer {
  component: string;
  props?: Record<string, any>;
}

// 模型类型
export const enum ModelType {
  NEWS = 'news',         // 新闻资讯
  PRODUCT = 'product',   // 产品展示
  CASE = 'case',        // 案例展示
  PAGE = 'page',        // 单页
  CATEGORY = 'category' // 分类
}

// 内容模型接口
export interface ContentModel {
  id: number;
  modelName: string;
  modelCode: string;
  modelType: ModelType;
  tableName: string;
  isSystem: string;
  state: string;
  remark?: string;
}

// 模型字段接口
export interface ModelField extends FieldConfig {
  id: number;
  modelId: number;
  validateRule?: string;
  remark?: string;
}

// API 响应数据结构
export interface ApiResponse<T> {
  code: number;
  msg: string;
  data: T;
  rows?: T[];
  total?: number;
}

// 查询参数接口
export interface ModelQuery extends PageQuery {
  modelName?: string;
  modelCode?: string;
  modelType?: string;
  state?: string;
}

// 表单数据接口
export interface ModelForm {
  id?: number;
  modelName: string;
  modelCode: string;
  modelType: ModelType;
  tableName: string;
  isSystem?: string;
  state?: string;
  remark?: string;
}

// 视图对象接口
export interface ModelVO extends ModelForm {
  createBy?: string;
  createTime?: string;
  updateBy?: string;
  updateTime?: string;
  state: string;
}



